home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Installer SDK Cornucopia 1.0.2 / Script Examples / File Compare by Procedure / GetFileVersion.c next >
Encoding:
Text File  |  1996-09-11  |  1.7 KB  |  63 lines  |  [TEXT/MPS ]

  1. //
  2. //    GetFileVersion.c
  3. //
  4. //        This code resource will be called as a Custom Version Compare
  5. //        Procedure ( 'invc' ) from within the "File Compare by Procedure"
  6. //        example.
  7. //
  8. //        The function below simply reads the first 4 bytes of the 'vers' (1)
  9. //        resource item of the currently selected file ( handle automatically
  10. //        by the Installer ), and returns that value. If a 'vers' (1) resource
  11. //        item cannot be found, then the value of the first four bytes of the
  12. //        'vers' (2) resource item is returned. If no 'vers' (1) or (2) resource
  13. //        items are found, then the function returns 0.
  14. //
  15. //        This by the way, is the default behavior of the Installer when
  16. //        ascertaining the version number of a file, so this function when
  17. //         implemented does not really do anything. But since this is a custom
  18. //        code resource, we don't really know what you'll want to do with it
  19. //        exactly. Customize this example as best fits the needs of your project.
  20. //
  21. //
  22. //        Copyright 1993-1996, Apple Computer, Inc., All Rights Reserved
  23. //
  24.  
  25.  
  26. #ifndef __OSUtils__
  27. #include <OSUtils.h>
  28. #endif
  29.  
  30. #ifndef __Errors__
  31. #include <Errors.h>
  32. #endif
  33.  
  34. #ifndef __Resources__
  35. #include <Resources.h>
  36. #endif
  37.  
  38. // NOTE: The name of this function 'GetFileVersion' should
  39. // match that specified in the -m option for the line in the
  40. // makefile that compiles this code resource.
  41. long GetFileVersion( void ) 
  42. {
  43.  
  44.     long    theVersionNum = 0;
  45.     long**    longHandle;
  46.  
  47.     longHandle = (long**) Get1Resource( 'vers', 1 );
  48.     
  49.     if ( longHandle != NULL && ResError() == noErr )
  50.         {
  51.         theVersionNum = **longHandle;
  52.         }
  53.     else 
  54.          {
  55.         longHandle = (long**) Get1Resource( 'vers', 2 );
  56.  
  57.         if ( longHandle != NULL && ResError() == noErr )
  58.             theVersionNum = **longHandle;
  59.         }
  60.     
  61.     return theVersionNum;
  62. }
  63.